<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>登录中</title>
    <script>
        (function () {
            if (window._tokenHtmlMsgListener) {
                return;
            }
            window._tokenHtmlMsgListener = true;
            var tokenHtmlMsgListener = (e) => {
                if (!e.data) {
                    throw new Error("非法");
                    return;
                }

                if (window.location.search.includes("log")) {
                    console.log(window.location.href, "收到message,origin:", e.origin, "数据:", e.data);
                }

                var token = e.data.token;
                if (!token) {
                    return;
                }
                var system = "@VUE_APP_USER_SYSTEM@",
                    tokeyKey = e.data.tokenKey || "token",
                    localTokenKey = tokeyKey;

                if (system) {
                    localTokenKey = system + ":" + localTokenKey
                }

                localStorage.setItem(localTokenKey, token)

                e.source.postMessage({event: tokeyKey + "_ack", system: system}, e.origin);
            }
            window.addEventListener('message', tokenHtmlMsgListener);
        })()
    </script>
</head>
<body>
</body>
</html>
